[inject templates/en.xd]
[style
  [rule .example;
    [: margin-block-end; .5rem]
    [: text-align; initial]
  ]
  [rule .example>dl>dt;
    [: display; inline]
    [: font-weight; bold]
  ]
  [rule .example>dl>dd;
    [: display; inline]
    [: margin; 0]
  ]
  [rule .example>dl>dd::after;
    [: content; '']
    [: display; block]
  ]
]
[gen-title Missing features of programming languages]
[p I have noticed that whenever a programming language is missing a feature, its users often tend to reimplement the feature in a way that is uglier, more complicated and more fragile, while arguing that adding the feature would make the language more complex.]
[section Examples; [<ul>
  [def ex; lang feature workaround;
    [<li> .example;
      [<dl>
        [<dt> Language:] [<dd> [arg lang]]
        [<dt> Feature:] [<dd> [arg feature]]
        [<dt> Workaround:] [<dd> [arg workaround]]
      ]
    ]
  ]
  [ex C; parametric polymorphism; [code c; void*], weird tricks with [code c; #include] & [code c; #define]]
  [ex C++ & Java; structural pattern matching; the “visitor pattern”]
  [ex Java (old versions); first-class functions; the “strategy pattern”]
  [ex Go (old versions); parametric polymorphism; [code go; interface{}], code generation]
  [ex Java; free-standing procedures; static classes]
  [ex C & C++; a proper module system; [code #include], header files, guards, [code #pragma once]]
  [ex Go; enums; [code go; iota] (no type safety)]
  [ex WebAssembly; DOM API; JavaScript glue code]
  [ex C; bit sets; [code-block c; [raw<
    #define STRAWBERRY (1 << 0)
    #define BANANA     (1 << 1)
    #define WATERMELON (1 << 2)
    #define APPLE      (1 << 3)
    /* no type safety */
  ]]]
  [ex JavaScript; statements as expressions; immediately-invoked functions]
  [ex C; sum types; tagged unions (no type safety)]
  [ex Java; named arguments; “builder pattern”]
  [ex C; optional types / exceptions; error codes]
]]
[section Honorable mentions;
  [list
    Haskell deals with missing features by having many language extensions, at the cost of creating 2[<sup> many] dialects;
  ]
]
